<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

<script src="jquery.js"></script>
<script>

  function axios({url, method = 'GET', data = null}) {
    return new Promise((resolve, reject) => {
      $.ajax({
        method,
        url,
        data,
        success(res){
          resolve(res)
        },
        error(e) {
          reject(e)
        }
      })
    })
  }

  let p1 = axios({
    url: 'https://gank.io/api/v2/banners123',
  })

  let p2 = axios({
    url: 'https://api.yizhanketang.cn/api/v1/todos',
  })

  let p3 = axios({
    url: 'https://veihwwnelcwq.leanapp.cn/bmi',
  })

  // console.log(p1)
  // console.log(p2)
  // console.log(p3)


  /*
  // [p1, p2, p3] 都成功，最终输出成功
  Promise.all([p1, p2, p3]).then(res => {
    console.log('success', res)
  }).catch(e => {
    console.log('error', e)
  })
  // [p1, p2, p3] 其中一个成功，最终输出成功
  // [p1, p2, p3] 都失败，最终输出失败
  Promise.any([p1, p2, p3])
  *//*
  // [p1, p2, p3] 谁率先改变就会改变最终状态
  Promise.race([p1, p2, p3]).then(res => {
    console.log('success', res)
  }).catch(e => {
    console.log('error', e)
  })*/







  /*axios({
    url: 'https://gank.io/api/v2/banners',
  }).then(res => {
    console.log(res)
  }).catch(e => {
    console.log(e)
  })*/

</script>
</body>
</html>